package com.mikelouis.test.scala.proginscala.chapter21

/**
 * Created by yuazhu on 2/1/2015.
 */
object ImplicitDebug extends App{

  //  def main(args: Array[String]) {
  //    val chars: List[Char] = stringWrapper("xyz")
  //
  //  }
  //
  //  implicit def stringWrapper(s: String) =
  //    new RandomAccessSeq[Char] {
  //      def length = s.length
  //
  //      def apply(i: Int) = s.charAt(i)
  //    }
  //
  //  def printWithSpaces(seq: RandomAccessSeq[Char]) =
  //    seq mkString " "

  class PreferredDrink(val preference: String)

  implicit val pref = new PreferredDrink("mocha")

  def enjoy(name: String)(implicit drink: PreferredDrink) {
    print("Welcome, " + name)
    print(". Enjoy a ")
    print(drink.preference)
    println("!")
  }

  enjoy("reader")
}
